<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input />
    <script>
        // 匹配所有字符 [\s\S] [\d\D]

        let str = `
            #1 js,200元 #
            #2 css,210元 #
            #3 node,200元 #
            #4 www.com,张三 # 李思
            #5 vue,100元 #
        `
        // 转为{name:'js',price:'200元'}格式
        // * 带0个或多个
        // m 每一行单独处理
        // u 匹配宽字节 不止占一个字节
        let obj = str.match(/^\s*#\d+\s+.+\s+#$/gm).map(item => {
            item = item.replace(/#\d\s+/, '').replace(/#/, '');
            [name, price] = item.trim().split(",")
            return { name, price }
        })
        console.log(JSON.stringify(obj, null, 2))

        let date = '2021/06/03';
        // \1使用前面的分组 ([\-\/])
        let reg = /^\d{4}([-\/])\d{2}\1\d{2}$/g;
        console.log(date.match(reg));

        document.querySelector('input').addEventListener('keyup', () => {
            console.log(this)
        })

        class User {
            constructor(name){
                this.name = name;
            }
            show(){
                console.log(this)
                function init(){
                    console.log(this)
                }
                init();
            }
        }
        const user = new User();
        user.show();
    </script>
</body>

</html>